<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>章节管理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link href="__CSS__/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__CSS__/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="__CSS__/animate.css" rel="stylesheet">
    <link href="__CSS__/style.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" href="__CSS__/home/book.css">
</head>

<body class="gray-bg">
<div><h1>章节管理</h1></div>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="container">
        <a href="{:url('Course/chapter_add')}?course_id={$course_id}">添加章节</a>
    </div>
</div>

<div class="container">
    <div class="row">
        {volist  name="chapter" id="value"}
        <!--循环部分 开始-->
        <div class="col-md-12  col-xs-12 row ">
            <!--按键部分-->
            <div class=" width-all btn btn-default dropdown-toggle notradius "  >

                <button class=" btn btn-xs pull-right"  onclick="show('logo{$value.id}','show{$value.id}')">
                    <span id="logo{$value.id}" class="glyphicon glyphicon-eye-close"></span>
                </button>
                <button class=" btn btn-xs pull-right">
                    <a href="{:url('Course/chapter_update')}?chapter_id={$value.id}&&course_id={$course_id}">修改</a>
                </button>
                <button class=" btn btn-xs pull-right"  >
                    <a onclick= "chapter_delete('{$value.id}')">删除</a>
                </button>
                <button class=" btn btn-xs pull-right"  >
                    <a href="{:url('Course/chapter_file_add')}?chapter_id={$value.id}&&course_id={$course_id}">添加课程</a>
                </button>
                <span class="glyphicon glyphicon-list pull-left " ></span>   第{$value.chapter_number}章节 {$value.chapter_name}

            </div>
            <!--课程部分-->

            <div class="width-all text-center"  style="display: none;" id="show{$value.id}">

                {volist name="value.file"  id="files"}
                <div class=" list-none text-left center-block" style="width: 80%;color: #000;line-height: 3rem" >

               <div  class="fora"><span class="glyphicon glyphicon-play"></span>  {$files.name}
                        <button class="btn btn-xs pull-right" onclick="chapter_course_delete('{$files.id}')">删除</button></div>
                </div>
                {/volist}
            </div>
        </div>
        <!--循环部分结束-->

        {/volist}


    </div>
</div>


<!-- 全局js -->
<script src="__JS__/jquery.min.js?v=2.1.4"></script>
<script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
<script src="__JS__/jquery.validate.js"> </script>

<!-- 自定义js -->
<script>
    var delete_chapter_id="{:url('Course/chapter_delete')}";

    function chang(obg) {
        if($(obg).val()==""){
            $(obg).siblings("span").text("选择文件")
        }else{disabled="disabled"
            $("#button1").css("disabled","disabled")
            $(obg).siblings("span").text($(obg).val())
        }
    }
    function deletes(id) {
        if(confirm("你确定要删除这个录播图片吗  ？！")){
            $.ajax({
                url:deleteurl,
                type:"post",
                dataType:"text",
                data:{
                    id:id
                },
                success:function (data) {
                    if(data=="1"){
                        alert("删除成功")
                        history.go(0)
                    }else{
                        alert("删除失败")
                    }
                },
                error:function (e) {
                    alert(e.response)
                }


            })
        }
    }
    function submits(obg) {
//        alert(123)
        alert($(obg).siblings().eq(1).val());
        if($(obg).siblings("input").val()==""){
            alert("你还没选择文件哦");
            return false;
        }else{
            return false;
        }
    }
    function show(logoid,id) {
        if( $("#"+logoid).attr("class")=="glyphicon glyphicon-eye-close"){
            $("#"+logoid).attr("class","glyphicon glyphicon-eye-open")
        }else{
            $("#"+logoid).attr("class","glyphicon glyphicon-eye-close")
        }
//        alert(123)
        if( $("#"+id).css("display")=="block"){
            $("#"+id).css("display","none")
        }else{
//           alert($("#"+id));
            $("#"+id).css("display","block")
        }
    }

    var url = "{:url('Course/chapter_course_delete')}";
    function chapter_course_delete(id) {
        if(confirm("删除？")){
//            alert(id);
            $.ajax({
                url:url,
                dataType:"text",
                type:"post",
                data:{
                    course_id:id
                },
                success:function (data) {
//                    alert(data);
                    if(data=="true"){
                        alert("删除成功")
                        history.go(0)
                    }else {
                        alert("删除失败")
                    }
                },
                error:function (e) {
                    alert(e.response)
                }

            })
        }

    }

    function chapter_delete(id) {
        if(confirm("删除这个章节？这还会删除这个章节下的所有课程！")){
            $.ajax({
                url:delete_chapter_id,
                dataType:"text",
                type:"post",
                data:{
                    chapter_id:id
                },
                success:function (data) {
//                    alert(data);
                    if(data=="true"){
                        alert("删除成功")
                        history.go(0)
                    }else {
                        alert("删除失败")
                    }
                },
                error:function (e) {
                    alert(e.response)
                }

            })
        }

    }


</script>
</body>

</html>
